package jjn.round1;

/**
 * @author Jjn
 * @since 2022/11/8 22:42
 */
public class LeetCode1684_CountConsistentStrings {
    public int countConsistentStrings(String allowed, String[] words) {
        boolean[] signs = new boolean[27];
        for (int i = 0; i < allowed.length(); i++) {
            signs[allowed.charAt(i) - 'a'] = true;
        }
        int total = 0;
        for (String word : words) {
            if (containsAll(signs, word)) {
                total++;
            }
        }
        return total;
    }

    private boolean containsAll(boolean[] signs, String word) {
        for (int i = 0; i < word.length(); i++) {
            char c = word.charAt(i);
            if (!signs[c - 'a']) {
                return false;
            }
        }
        return true;
    }
}
